# Maintainer: Danila Tikhonov <danila@jiaxyga.com>
# Co-Maintainer: David Wronek <david@mainlining.org>
# Co-Maintainer: Jens Reidel <adrian@travitia.xyz>

_flavor="postmarketos-qcom-sm7150"
pkgname=linux-$_flavor
pkgver=6.7.4
pkgrel=2
_pkgrel=0
pkgdesc="Mainline Kernel fork for SM7150 devices"
arch="aarch64"
_carch="arm64"
url="https://github.com/sm7150-mainline/linux"
license="GPL-2.0-only"
options="!strip !check !tracedeps
	pmb:cross-native
	pmb:kconfigcheck-nftables
	"
makedepends="bison findutils flex openssl-dev perl postmarketos-installkernel"

_tag="$pkgver-r$_pkgrel"

# Source
source="
	$pkgname-v$_tag.tar.gz::$url/archive/v$_tag.tar.gz
	config-$_flavor.$arch
"
builddir="$srcdir/linux-$_tag"

prepare() {
	default_prepare
	cp "$srcdir/config-$_flavor.$arch" .config
}

build() {
	unset LDFLAGS
	make ARCH="$_carch" CC="${CC:-gcc}" \
		KBUILD_BUILD_VERSION="$((_pkgrel + 1 ))-$_flavor"
}

package() {
	mkdir -p "$pkgdir"/boot
	make zinstall modules_install dtbs_install \
		ARCH="$_carch" \
		INSTALL_PATH="$pkgdir"/boot/ \
		INSTALL_MOD_PATH="$pkgdir" \
		INSTALL_MOD_STRIP=1 \
		INSTALL_DTBS_PATH="$pkgdir"/boot/dtbs
	rm -f "$pkgdir"/lib/modules/*/build "$pkgdir"/lib/modules/*/source

	install -D "$builddir"/include/config/kernel.release \
		"$pkgdir"/usr/share/kernel/$_flavor/kernel.release
}


sha512sums="
e5159ef56d28f2e4cc071801c82255d8aa047cc9066aa491ac5a7094eae4b08ec217c042b166cf081e34292b1b6ff957d86545e590d585f3d9516020a37cfb8c  linux-postmarketos-qcom-sm7150-v6.7.4-r0.tar.gz
423638d01da98dc7c9358c35c0d7813b8c58a922a9e5ffb3433675bc0ab8687661aaef5e7c279e14b06c7c18ad993b4a91aabaf5336f6da64e14878ba8c43477  config-postmarketos-qcom-sm7150.aarch64
"
